package com.sunda.spmswms.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sunda.spmswms.entity.CostCenter;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 仓库信息表 Mapper 接口
 * </p>
 *
 * @author Wayne
 * @since 2020-11-24
 */
@Mapper
@Component
public interface CostCenterMapper extends BaseMapper<CostCenter> {

    @Select("SELECT W.WERKS AS \"werks\",\n" +
            "       CC.COMPANY_CODE AS \"companyCode\",\n" +
            "       CC.COST_CENTER_CODE AS \"costCenterCode\",\n" +
            "       CC.COST_CENTER_NAME AS \"costCenterName\"\n" +
            "FROM WERKS W\n" +
            "    LEFT JOIN COST_CENTER CC ON W.COMPANY_CODE = CC.COMPANY_CODE\n" +
            "WHERE W.WERKS = #{werks} ORDER BY CC.COST_CENTER_CODE ")
    List<Map<String, Object>> getCostCenterByWerks(@Param("werks") String werks);
}
